package com.td.erhome.ui;

import android.content.Intent;
import android.widget.Button;

import com.acker.simplezxing.activity.CaptureActivity;
import com.td.erhome.R;
import com.td.erhome.base.BaseActivity;

import butterknife.Bind;
import butterknife.OnClick;

public class ZxCodeActivity extends BaseActivity {

    @Bind(R.id.onclic)
    Button mOnclic;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_zx_code;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void releaseResource() {

    }

    @OnClick(R.id.onclic)
    public void onViewClicked() {
        startActivityForResult(new Intent(this, CaptureActivity.class), CaptureActivity.REQ_CODE);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case CaptureActivity.REQ_CODE:
                switch (resultCode) {
                    case RESULT_OK:
                     //   tvResult.setText(data.getStringExtra(CaptureActivity.EXTRA_SCAN_RESULT));  //or do sth
                        break;
                    case RESULT_CANCELED:
                        if (data != null) {
                            // for some reason camera is not working correctly
                         //   tvResult.setText(data.getStringExtra(CaptureActivity.EXTRA_SCAN_RESULT));
                        }
                        break;
                }
                break;
        }
    }
}
